home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7697 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  50 lines

  1. Path: robertk.accessone.com!user
  2. From: robertk@accessone.com (robertk)
  3. Newsgroups: comp.lang.c
  4. Subject: very simple newbie question
  5. Date: 28 Feb 1996 07:13:20 GMT
  6. Organization: Kingdom
  7. Message-ID: <robertk-2802960012350001@robertk.accessone.com>
  8. NNTP-Posting-Host: robertk.accessone.com
  9.  
  10. how come.....
  11.          
  12.             #include <stdio.h>
  13.             main()
  14.             {
  15.               char s[10];
  16.               scanf("%s",s);
  17.               printf("%s",s);
  18.              }
  19.  
  20.             when i run this and input:
  21.  
  22.                   robert <enter> --->soon as i hit the enter key i am 
  23.                                     thrown back to the ide-upon returning to 
  24.                                     the screen i see 
  25.                   robert
  26.                   robert 
  27.  
  28.                BUT...........
  29.  
  30.              #include <stdio.h>
  31.              main()
  32.              {
  33.               char s[10];
  34.               scanf("%s/n",s);
  35.               printf("%s",s);
  36.              }
  37.  
  38.             when i run this and input:
  39.  
  40.                   robert <enter> --->when i hit the enter key the cursor 
  41.                                      drops down a line and sits ther flashing
  42.                                      waiting for me to enter another character
  43.                                      like x before it will throw me back to the
  44.                                      ide. upon returning to the screen i see
  45.                   robert
  46.                   x
  47.                   robert
  48.  
  49.                i thought scanf() ignored whitespace?
  50.